﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameContent.UI.Elements;

namespace Terraria.UI
{
	// Token: 0x02000119 RID: 281
	public class UIElement : IComparable
	{
		// Token: 0x1400000D RID: 13
		// (add) Token: 0x06000C3E RID: 3134 RVA: 0x003F3740 File Offset: 0x003F1940
		// (remove) Token: 0x06000C3F RID: 3135 RVA: 0x003F3778 File Offset: 0x003F1978
		public event UIElement.MouseEvent OnMouseDown;

		// Token: 0x1400000E RID: 14
		// (add) Token: 0x06000C40 RID: 3136 RVA: 0x003F37B0 File Offset: 0x003F19B0
		// (remove) Token: 0x06000C41 RID: 3137 RVA: 0x003F37E8 File Offset: 0x003F19E8
		public event UIElement.MouseEvent OnMouseUp;

		// Token: 0x1400000F RID: 15
		// (add) Token: 0x06000C42 RID: 3138 RVA: 0x003F3820 File Offset: 0x003F1A20
		// (remove) Token: 0x06000C43 RID: 3139 RVA: 0x003F3858 File Offset: 0x003F1A58
		public event UIElement.MouseEvent OnClick;

		// Token: 0x14000010 RID: 16
		// (add) Token: 0x06000C44 RID: 3140 RVA: 0x003F3890 File Offset: 0x003F1A90
		// (remove) Token: 0x06000C45 RID: 3141 RVA: 0x003F38C8 File Offset: 0x003F1AC8
		public event UIElement.MouseEvent OnMouseOver;

		// Token: 0x14000011 RID: 17
		// (add) Token: 0x06000C46 RID: 3142 RVA: 0x003F3900 File Offset: 0x003F1B00
		// (remove) Token: 0x06000C47 RID: 3143 RVA: 0x003F3938 File Offset: 0x003F1B38
		public event UIElement.MouseEvent OnMouseOut;

		// Token: 0x14000012 RID: 18
		// (add) Token: 0x06000C48 RID: 3144 RVA: 0x003F3970 File Offset: 0x003F1B70
		// (remove) Token: 0x06000C49 RID: 3145 RVA: 0x003F39A8 File Offset: 0x003F1BA8
		public event UIElement.MouseEvent OnDoubleClick;

		// Token: 0x14000013 RID: 19
		// (add) Token: 0x06000C4A RID: 3146 RVA: 0x003F39E0 File Offset: 0x003F1BE0
		// (remove) Token: 0x06000C4B RID: 3147 RVA: 0x003F3A18 File Offset: 0x003F1C18
		public event UIElement.MouseEvent OnRightMouseDown;

		// Token: 0x14000014 RID: 20
		// (add) Token: 0x06000C4C RID: 3148 RVA: 0x003F3A50 File Offset: 0x003F1C50
		// (remove) Token: 0x06000C4D RID: 3149 RVA: 0x003F3A88 File Offset: 0x003F1C88
		public event UIElement.MouseEvent OnRightMouseUp;

		// Token: 0x14000015 RID: 21
		// (add) Token: 0x06000C4E RID: 3150 RVA: 0x003F3AC0 File Offset: 0x003F1CC0
		// (remove) Token: 0x06000C4F RID: 3151 RVA: 0x003F3AF8 File Offset: 0x003F1CF8
		public event UIElement.MouseEvent OnRightClick;

		// Token: 0x14000016 RID: 22
		// (add) Token: 0x06000C50 RID: 3152 RVA: 0x003F3B30 File Offset: 0x003F1D30
		// (remove) Token: 0x06000C51 RID: 3153 RVA: 0x003F3B68 File Offset: 0x003F1D68
		public event UIElement.MouseEvent OnRightDoubleClick;

		// Token: 0x14000017 RID: 23
		// (add) Token: 0x06000C52 RID: 3154 RVA: 0x003F3BA0 File Offset: 0x003F1DA0
		// (remove) Token: 0x06000C53 RID: 3155 RVA: 0x003F3BD8 File Offset: 0x003F1DD8
		public event UIElement.MouseEvent OnMiddleMouseDown;

		// Token: 0x14000018 RID: 24
		// (add) Token: 0x06000C54 RID: 3156 RVA: 0x003F3C10 File Offset: 0x003F1E10
		// (remove) Token: 0x06000C55 RID: 3157 RVA: 0x003F3C48 File Offset: 0x003F1E48
		public event UIElement.MouseEvent OnMiddleMouseUp;

		// Token: 0x14000019 RID: 25
		// (add) Token: 0x06000C56 RID: 3158 RVA: 0x003F3C80 File Offset: 0x003F1E80
		// (remove) Token: 0x06000C57 RID: 3159 RVA: 0x003F3CB8 File Offset: 0x003F1EB8
		public event UIElement.MouseEvent OnMiddleClick;

		// Token: 0x1400001A RID: 26
		// (add) Token: 0x06000C58 RID: 3160 RVA: 0x003F3CF0 File Offset: 0x003F1EF0
		// (remove) Token: 0x06000C59 RID: 3161 RVA: 0x003F3D28 File Offset: 0x003F1F28
		public event UIElement.MouseEvent OnMiddleDoubleClick;

		// Token: 0x1400001B RID: 27
		// (add) Token: 0x06000C5A RID: 3162 RVA: 0x003F3D60 File Offset: 0x003F1F60
		// (remove) Token: 0x06000C5B RID: 3163 RVA: 0x003F3D98 File Offset: 0x003F1F98
		public event UIElement.MouseEvent OnXButton1MouseDown;

		// Token: 0x1400001C RID: 28
		// (add) Token: 0x06000C5C RID: 3164 RVA: 0x003F3DD0 File Offset: 0x003F1FD0
		// (remove) Token: 0x06000C5D RID: 3165 RVA: 0x003F3E08 File Offset: 0x003F2008
		public event UIElement.MouseEvent OnXButton1MouseUp;

		// Token: 0x1400001D RID: 29
		// (add) Token: 0x06000C5E RID: 3166 RVA: 0x003F3E40 File Offset: 0x003F2040
		// (remove) Token: 0x06000C5F RID: 3167 RVA: 0x003F3E78 File Offset: 0x003F2078
		public event UIElement.MouseEvent OnXButton1Click;

		// Token: 0x1400001E RID: 30
		// (add) Token: 0x06000C60 RID: 3168 RVA: 0x003F3EB0 File Offset: 0x003F20B0
		// (remove) Token: 0x06000C61 RID: 3169 RVA: 0x003F3EE8 File Offset: 0x003F20E8
		public event UIElement.MouseEvent OnXButton1DoubleClick;

		// Token: 0x1400001F RID: 31
		// (add) Token: 0x06000C62 RID: 3170 RVA: 0x003F3F20 File Offset: 0x003F2120
		// (remove) Token: 0x06000C63 RID: 3171 RVA: 0x003F3F58 File Offset: 0x003F2158
		public event UIElement.MouseEvent OnXButton2MouseDown;

		// Token: 0x14000020 RID: 32
		// (add) Token: 0x06000C64 RID: 3172 RVA: 0x003F3F90 File Offset: 0x003F2190
		// (remove) Token: 0x06000C65 RID: 3173 RVA: 0x003F3FC8 File Offset: 0x003F21C8
		public event UIElement.MouseEvent OnXButton2MouseUp;

		// Token: 0x14000021 RID: 33
		// (add) Token: 0x06000C66 RID: 3174 RVA: 0x003F4000 File Offset: 0x003F2200
		// (remove) Token: 0x06000C67 RID: 3175 RVA: 0x003F4038 File Offset: 0x003F2238
		public event UIElement.MouseEvent OnXButton2Click;

		// Token: 0x14000022 RID: 34
		// (add) Token: 0x06000C68 RID: 3176 RVA: 0x003F4070 File Offset: 0x003F2270
		// (remove) Token: 0x06000C69 RID: 3177 RVA: 0x003F40A8 File Offset: 0x003F22A8
		public event UIElement.MouseEvent OnXButton2DoubleClick;

		// Token: 0x14000023 RID: 35
		// (add) Token: 0x06000C6A RID: 3178 RVA: 0x003F40E0 File Offset: 0x003F22E0
		// (remove) Token: 0x06000C6B RID: 3179 RVA: 0x003F4118 File Offset: 0x003F2318
		public event UIElement.ScrollWheelEvent OnScrollWheel;

		// Token: 0x170000DA RID: 218
		// (get) Token: 0x06000C6C RID: 3180 RVA: 0x0000C843 File Offset: 0x0000AA43
		public bool IsMouseHovering
		{
			get
			{
				return this._isMouseHovering;
			}
		}

		// Token: 0x06000C6D RID: 3181 RVA: 0x003F4150 File Offset: 0x003F2350
		public UIElement()
		{
			if (UIElement._overflowHiddenRasterizerState == null)
			{
				UIElement._overflowHiddenRasterizerState = new RasterizerState
				{
					CullMode = CullMode.None,
					ScissorTestEnable = true
				};
			}
		}

		// Token: 0x06000C6E RID: 3182 RVA: 0x003F41C4 File Offset: 0x003F23C4
		public void SetSnapPoint(string name, int id, Vector2? anchor = null, Vector2? offset = null)
		{
			if (anchor == null)
			{
				anchor = new Vector2?(new Vector2(0.5f));
			}
			if (offset == null)
			{
				offset = new Vector2?(Vector2.Zero);
			}
			this._snapPoint = new SnapPoint(name, id, anchor.Value, offset.Value);
		}

		// Token: 0x06000C6F RID: 3183 RVA: 0x0000C84B File Offset: 0x0000AA4B
		public bool GetSnapPoint(out SnapPoint point)
		{
			point = this._snapPoint;
			if (this._snapPoint != null)
			{
				this._snapPoint.Calculate(this);
			}
			return this._snapPoint != null;
		}

		// Token: 0x06000C70 RID: 3184 RVA: 0x00006B58 File Offset: 0x00004D58
		protected virtual void DrawSelf(SpriteBatch spriteBatch)
		{
		}

		// Token: 0x06000C71 RID: 3185 RVA: 0x003F421C File Offset: 0x003F241C
		protected virtual void DrawChildren(SpriteBatch spriteBatch)
		{
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Draw(spriteBatch);
			}
		}

		// Token: 0x06000C72 RID: 3186 RVA: 0x0000C872 File Offset: 0x0000AA72
		public void Append(UIElement element)
		{
			element.Remove();
			element.Parent = this;
			this.Elements.Add(element);
			element.Recalculate();
		}

		// Token: 0x06000C73 RID: 3187 RVA: 0x0000C893 File Offset: 0x0000AA93
		public void Remove()
		{
			if (this.Parent != null)
			{
				this.Parent.RemoveChild(this);
			}
		}

		// Token: 0x06000C74 RID: 3188 RVA: 0x0000C8A9 File Offset: 0x0000AAA9
		public void RemoveChild(UIElement child)
		{
			this.Elements.Remove(child);
			child.Parent = null;
		}

		// Token: 0x06000C75 RID: 3189 RVA: 0x003F4270 File Offset: 0x003F2470
		public void RemoveAllChildren()
		{
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Parent = null;
			}
			this.Elements.Clear();
		}

		// Token: 0x06000C76 RID: 3190 RVA: 0x0000C8BF File Offset: 0x0000AABF
		public bool HasChild(UIElement child)
		{
			return this.Elements.Contains(child);
		}

		// Token: 0x06000C77 RID: 3191 RVA: 0x003F42D0 File Offset: 0x003F24D0
		public virtual void Draw(SpriteBatch spriteBatch)
		{
			bool overflowHidden = this.OverflowHidden;
			bool useImmediateMode = this._useImmediateMode;
			RasterizerState rasterizerState = spriteBatch.GraphicsDevice.RasterizerState;
			Rectangle scissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle;
			SamplerState anisotropicClamp = SamplerState.AnisotropicClamp;
			if (useImmediateMode)
			{
				spriteBatch.End();
				spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, null, Main.UIScaleMatrix);
				this.DrawSelf(spriteBatch);
				spriteBatch.End();
				spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, null, Main.UIScaleMatrix);
			}
			else
			{
				this.DrawSelf(spriteBatch);
			}
			if (overflowHidden)
			{
				spriteBatch.End();
				Rectangle clippingRectangle = this.GetClippingRectangle(spriteBatch);
				spriteBatch.GraphicsDevice.ScissorRectangle = clippingRectangle;
				spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, null, Main.UIScaleMatrix);
			}
			this.DrawChildren(spriteBatch);
			if (overflowHidden)
			{
				spriteBatch.End();
				spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
				spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, rasterizerState, null, Main.UIScaleMatrix);
			}
		}

		// Token: 0x06000C78 RID: 3192 RVA: 0x003F43D8 File Offset: 0x003F25D8
		public virtual void Update(GameTime gameTime)
		{
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Update(gameTime);
			}
		}

		// Token: 0x06000C79 RID: 3193 RVA: 0x003F442C File Offset: 0x003F262C
		public Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
		{
			Vector2 vector = new Vector2(this._innerDimensions.X, this._innerDimensions.Y);
			Vector2 vector2 = new Vector2(this._innerDimensions.Width, this._innerDimensions.Height) + vector;
			vector = Vector2.Transform(vector, Main.UIScaleMatrix);
			vector2 = Vector2.Transform(vector2, Main.UIScaleMatrix);
			Rectangle rectangle = new Rectangle((int)vector.X, (int)vector.Y, (int)(vector2.X - vector.X), (int)(vector2.Y - vector.Y));
			int width = spriteBatch.GraphicsDevice.Viewport.Width;
			int height = spriteBatch.GraphicsDevice.Viewport.Height;
			rectangle.X = Utils.Clamp<int>(rectangle.X, 0, width);
			rectangle.Y = Utils.Clamp<int>(rectangle.Y, 0, height);
			rectangle.Width = Utils.Clamp<int>(rectangle.Width, 0, width - rectangle.X);
			rectangle.Height = Utils.Clamp<int>(rectangle.Height, 0, height - rectangle.Y);
			return rectangle;
		}

		// Token: 0x06000C7A RID: 3194 RVA: 0x003F4550 File Offset: 0x003F2750
		public virtual List<SnapPoint> GetSnapPoints()
		{
			List<SnapPoint> list = new List<SnapPoint>();
			SnapPoint item;
			if (this.GetSnapPoint(out item))
			{
				list.Add(item);
			}
			foreach (UIElement uielement in this.Elements)
			{
				list.AddRange(uielement.GetSnapPoints());
			}
			return list;
		}

		// Token: 0x06000C7B RID: 3195 RVA: 0x003F45C0 File Offset: 0x003F27C0
		public virtual void Recalculate()
		{
			CalculatedStyle calculatedStyle;
			if (this.Parent != null)
			{
				calculatedStyle = this.Parent.GetInnerDimensions();
			}
			else
			{
				calculatedStyle = UserInterface.ActiveInstance.GetDimensions();
			}
			if (this.Parent != null && this.Parent is UIList)
			{
				calculatedStyle.Height = float.MaxValue;
			}
			CalculatedStyle calculatedStyle2;
			calculatedStyle2.X = this.Left.GetValue(calculatedStyle.Width) + calculatedStyle.X;
			calculatedStyle2.Y = this.Top.GetValue(calculatedStyle.Height) + calculatedStyle.Y;
			float value = this.MinWidth.GetValue(calculatedStyle.Width);
			float value2 = this.MaxWidth.GetValue(calculatedStyle.Width);
			float value3 = this.MinHeight.GetValue(calculatedStyle.Height);
			float value4 = this.MaxHeight.GetValue(calculatedStyle.Height);
			calculatedStyle2.Width = MathHelper.Clamp(this.Width.GetValue(calculatedStyle.Width), value, value2);
			calculatedStyle2.Height = MathHelper.Clamp(this.Height.GetValue(calculatedStyle.Height), value3, value4);
			calculatedStyle2.Width += this.MarginLeft + this.MarginRight;
			calculatedStyle2.Height += this.MarginTop + this.MarginBottom;
			calculatedStyle2.X += calculatedStyle.Width * this.HAlign - calculatedStyle2.Width * this.HAlign;
			calculatedStyle2.Y += calculatedStyle.Height * this.VAlign - calculatedStyle2.Height * this.VAlign;
			this._outerDimensions = calculatedStyle2;
			calculatedStyle2.X += this.MarginLeft;
			calculatedStyle2.Y += this.MarginTop;
			calculatedStyle2.Width -= this.MarginLeft + this.MarginRight;
			calculatedStyle2.Height -= this.MarginTop + this.MarginBottom;
			this._dimensions = calculatedStyle2;
			calculatedStyle2.X += this.PaddingLeft;
			calculatedStyle2.Y += this.PaddingTop;
			calculatedStyle2.Width -= this.PaddingLeft + this.PaddingRight;
			calculatedStyle2.Height -= this.PaddingTop + this.PaddingBottom;
			this._innerDimensions = calculatedStyle2;
			this.RecalculateChildren();
		}

		// Token: 0x06000C7C RID: 3196 RVA: 0x003F4814 File Offset: 0x003F2A14
		public UIElement GetElementAt(Vector2 point)
		{
			UIElement uielement = null;
			foreach (UIElement uielement2 in this.Elements)
			{
				if (uielement2.ContainsPoint(point))
				{
					uielement = uielement2;
					break;
				}
			}
			if (uielement != null)
			{
				return uielement.GetElementAt(point);
			}
			if (this.ContainsPoint(point))
			{
				return this;
			}
			return null;
		}

		// Token: 0x06000C7D RID: 3197 RVA: 0x003F4888 File Offset: 0x003F2A88
		public virtual bool ContainsPoint(Vector2 point)
		{
			return point.X > this._dimensions.X && point.Y > this._dimensions.Y && point.X < this._dimensions.X + this._dimensions.Width && point.Y < this._dimensions.Y + this._dimensions.Height;
		}

		// Token: 0x06000C7E RID: 3198 RVA: 0x0000C8CD File Offset: 0x0000AACD
		public void SetPadding(float pixels)
		{
			this.PaddingBottom = pixels;
			this.PaddingLeft = pixels;
			this.PaddingRight = pixels;
			this.PaddingTop = pixels;
		}

		// Token: 0x06000C7F RID: 3199 RVA: 0x003F48FC File Offset: 0x003F2AFC
		public virtual void RecalculateChildren()
		{
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Recalculate();
			}
		}

		// Token: 0x06000C80 RID: 3200 RVA: 0x0000C8EB File Offset: 0x0000AAEB
		public CalculatedStyle GetInnerDimensions()
		{
			return this._innerDimensions;
		}

		// Token: 0x06000C81 RID: 3201 RVA: 0x0000C8F3 File Offset: 0x0000AAF3
		public CalculatedStyle GetDimensions()
		{
			return this._dimensions;
		}

		// Token: 0x06000C82 RID: 3202 RVA: 0x0000C8FB File Offset: 0x0000AAFB
		public CalculatedStyle GetOuterDimensions()
		{
			return this._outerDimensions;
		}

		// Token: 0x06000C83 RID: 3203 RVA: 0x003F4950 File Offset: 0x003F2B50
		public void CopyStyle(UIElement element)
		{
			this.Top = element.Top;
			this.Left = element.Left;
			this.Width = element.Width;
			this.Height = element.Height;
			this.PaddingBottom = element.PaddingBottom;
			this.PaddingLeft = element.PaddingLeft;
			this.PaddingRight = element.PaddingRight;
			this.PaddingTop = element.PaddingTop;
			this.HAlign = element.HAlign;
			this.VAlign = element.VAlign;
			this.MinWidth = element.MinWidth;
			this.MaxWidth = element.MaxWidth;
			this.MinHeight = element.MinHeight;
			this.MaxHeight = element.MaxHeight;
			this.Recalculate();
		}

		// Token: 0x06000C84 RID: 3204 RVA: 0x0000C903 File Offset: 0x0000AB03
		public virtual void MouseDown(UIMouseEvent evt)
		{
			if (this.OnMouseDown != null)
			{
				this.OnMouseDown(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MouseDown(evt);
			}
		}

		// Token: 0x06000C85 RID: 3205 RVA: 0x0000C92E File Offset: 0x0000AB2E
		public virtual void MouseUp(UIMouseEvent evt)
		{
			if (this.OnMouseUp != null)
			{
				this.OnMouseUp(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MouseUp(evt);
			}
		}

		// Token: 0x06000C86 RID: 3206 RVA: 0x0000C959 File Offset: 0x0000AB59
		public virtual void MouseOver(UIMouseEvent evt)
		{
			this._isMouseHovering = true;
			if (this.OnMouseOver != null)
			{
				this.OnMouseOver(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MouseOver(evt);
			}
		}

		// Token: 0x06000C87 RID: 3207 RVA: 0x0000C98B File Offset: 0x0000AB8B
		public virtual void MouseOut(UIMouseEvent evt)
		{
			this._isMouseHovering = false;
			if (this.OnMouseOut != null)
			{
				this.OnMouseOut(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MouseOut(evt);
			}
		}

		// Token: 0x06000C88 RID: 3208 RVA: 0x0000C9BD File Offset: 0x0000ABBD
		public virtual void Click(UIMouseEvent evt)
		{
			if (this.OnClick != null)
			{
				this.OnClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.Click(evt);
			}
		}

		// Token: 0x06000C89 RID: 3209 RVA: 0x0000C9E8 File Offset: 0x0000ABE8
		public virtual void DoubleClick(UIMouseEvent evt)
		{
			if (this.OnDoubleClick != null)
			{
				this.OnDoubleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.DoubleClick(evt);
			}
		}

		// Token: 0x06000C8A RID: 3210 RVA: 0x0000CA13 File Offset: 0x0000AC13
		public virtual void RightMouseDown(UIMouseEvent evt)
		{
			if (this.OnRightMouseDown != null)
			{
				this.OnRightMouseDown(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.RightMouseDown(evt);
			}
		}

		// Token: 0x06000C8B RID: 3211 RVA: 0x0000CA3E File Offset: 0x0000AC3E
		public virtual void RightMouseUp(UIMouseEvent evt)
		{
			if (this.OnRightMouseUp != null)
			{
				this.OnRightMouseUp(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.RightMouseUp(evt);
			}
		}

		// Token: 0x06000C8C RID: 3212 RVA: 0x0000CA69 File Offset: 0x0000AC69
		public virtual void RightClick(UIMouseEvent evt)
		{
			if (this.OnRightClick != null)
			{
				this.OnRightClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.RightClick(evt);
			}
		}

		// Token: 0x06000C8D RID: 3213 RVA: 0x0000CA94 File Offset: 0x0000AC94
		public virtual void RightDoubleClick(UIMouseEvent evt)
		{
			if (this.OnRightDoubleClick != null)
			{
				this.OnRightDoubleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.RightDoubleClick(evt);
			}
		}

		// Token: 0x06000C8E RID: 3214 RVA: 0x0000CABF File Offset: 0x0000ACBF
		public virtual void MiddleMouseDown(UIMouseEvent evt)
		{
			if (this.OnMiddleMouseDown != null)
			{
				this.OnMiddleMouseDown(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MiddleMouseDown(evt);
			}
		}

		// Token: 0x06000C8F RID: 3215 RVA: 0x0000CAEA File Offset: 0x0000ACEA
		public virtual void MiddleMouseUp(UIMouseEvent evt)
		{
			if (this.OnMiddleMouseUp != null)
			{
				this.OnMiddleMouseUp(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MiddleMouseUp(evt);
			}
		}

		// Token: 0x06000C90 RID: 3216 RVA: 0x0000CB15 File Offset: 0x0000AD15
		public virtual void MiddleClick(UIMouseEvent evt)
		{
			if (this.OnMiddleClick != null)
			{
				this.OnMiddleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MiddleClick(evt);
			}
		}

		// Token: 0x06000C91 RID: 3217 RVA: 0x0000CB40 File Offset: 0x0000AD40
		public virtual void MiddleDoubleClick(UIMouseEvent evt)
		{
			if (this.OnMiddleDoubleClick != null)
			{
				this.OnMiddleDoubleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.MiddleDoubleClick(evt);
			}
		}

		// Token: 0x06000C92 RID: 3218 RVA: 0x0000CB6B File Offset: 0x0000AD6B
		public virtual void XButton1MouseDown(UIMouseEvent evt)
		{
			if (this.OnXButton1MouseDown != null)
			{
				this.OnXButton1MouseDown(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton1MouseDown(evt);
			}
		}

		// Token: 0x06000C93 RID: 3219 RVA: 0x0000CB96 File Offset: 0x0000AD96
		public virtual void XButton1MouseUp(UIMouseEvent evt)
		{
			if (this.OnXButton1MouseUp != null)
			{
				this.OnXButton1MouseUp(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton1MouseUp(evt);
			}
		}

		// Token: 0x06000C94 RID: 3220 RVA: 0x0000CBC1 File Offset: 0x0000ADC1
		public virtual void XButton1Click(UIMouseEvent evt)
		{
			if (this.OnXButton1Click != null)
			{
				this.OnXButton1Click(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton1Click(evt);
			}
		}

		// Token: 0x06000C95 RID: 3221 RVA: 0x0000CBEC File Offset: 0x0000ADEC
		public virtual void XButton1DoubleClick(UIMouseEvent evt)
		{
			if (this.OnXButton1DoubleClick != null)
			{
				this.OnXButton1DoubleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton1DoubleClick(evt);
			}
		}

		// Token: 0x06000C96 RID: 3222 RVA: 0x0000CC17 File Offset: 0x0000AE17
		public virtual void XButton2MouseDown(UIMouseEvent evt)
		{
			if (this.OnXButton2MouseDown != null)
			{
				this.OnXButton2MouseDown(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton2MouseDown(evt);
			}
		}

		// Token: 0x06000C97 RID: 3223 RVA: 0x0000CC42 File Offset: 0x0000AE42
		public virtual void XButton2MouseUp(UIMouseEvent evt)
		{
			if (this.OnXButton2MouseUp != null)
			{
				this.OnXButton2MouseUp(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton2MouseUp(evt);
			}
		}

		// Token: 0x06000C98 RID: 3224 RVA: 0x0000CC6D File Offset: 0x0000AE6D
		public virtual void XButton2Click(UIMouseEvent evt)
		{
			if (this.OnXButton2Click != null)
			{
				this.OnXButton2Click(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton2Click(evt);
			}
		}

		// Token: 0x06000C99 RID: 3225 RVA: 0x0000CC98 File Offset: 0x0000AE98
		public virtual void XButton2DoubleClick(UIMouseEvent evt)
		{
			if (this.OnXButton2DoubleClick != null)
			{
				this.OnXButton2DoubleClick(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.XButton2DoubleClick(evt);
			}
		}

		// Token: 0x06000C9A RID: 3226 RVA: 0x0000CCC3 File Offset: 0x0000AEC3
		public virtual void ScrollWheel(UIScrollWheelEvent evt)
		{
			if (this.OnScrollWheel != null)
			{
				this.OnScrollWheel(evt, this);
			}
			if (this.Parent != null)
			{
				this.Parent.ScrollWheel(evt);
			}
		}

		// Token: 0x06000C9B RID: 3227 RVA: 0x003F4A0C File Offset: 0x003F2C0C
		public void Activate()
		{
			if (!this._isInitialized)
			{
				this.Initialize();
			}
			this.OnActivate();
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Activate();
			}
		}

		// Token: 0x06000C9C RID: 3228 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnActivate()
		{
		}

		// Token: 0x06000C9D RID: 3229 RVA: 0x003F4A74 File Offset: 0x003F2C74
		public void Deactivate()
		{
			this.OnDeactivate();
			foreach (UIElement uielement in this.Elements)
			{
				uielement.Deactivate();
			}
		}

		// Token: 0x06000C9E RID: 3230 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnDeactivate()
		{
		}

		// Token: 0x06000C9F RID: 3231 RVA: 0x0000CCEE File Offset: 0x0000AEEE
		public void Initialize()
		{
			this.OnInitialize();
			this._isInitialized = true;
		}

		// Token: 0x06000CA0 RID: 3232 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnInitialize()
		{
		}

		// Token: 0x06000CA1 RID: 3233 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual int CompareTo(object obj)
		{
			return 0;
		}

		// Token: 0x06000CA2 RID: 3234 RVA: 0x0000CCFD File Offset: 0x0000AEFD
		public virtual bool PassFilters()
		{
			throw new NotImplementedException();
		}

		// Token: 0x04001013 RID: 4115
		public string Id = "";

		// Token: 0x04001014 RID: 4116
		public UIElement Parent;

		// Token: 0x04001015 RID: 4117
		protected List<UIElement> Elements = new List<UIElement>();

		// Token: 0x04001016 RID: 4118
		public StyleDimension Top;

		// Token: 0x04001017 RID: 4119
		public StyleDimension Left;

		// Token: 0x04001018 RID: 4120
		public StyleDimension Width;

		// Token: 0x04001019 RID: 4121
		public StyleDimension Height;

		// Token: 0x0400101A RID: 4122
		public StyleDimension MaxWidth = StyleDimension.Fill;

		// Token: 0x0400101B RID: 4123
		public StyleDimension MaxHeight = StyleDimension.Fill;

		// Token: 0x0400101C RID: 4124
		public StyleDimension MinWidth = StyleDimension.Empty;

		// Token: 0x0400101D RID: 4125
		public StyleDimension MinHeight = StyleDimension.Empty;

		// Token: 0x0400101E RID: 4126
		private bool _isInitialized;

		// Token: 0x0400101F RID: 4127
		public bool OverflowHidden;

		// Token: 0x04001020 RID: 4128
		public float PaddingTop;

		// Token: 0x04001021 RID: 4129
		public float PaddingLeft;

		// Token: 0x04001022 RID: 4130
		public float PaddingRight;

		// Token: 0x04001023 RID: 4131
		public float PaddingBottom;

		// Token: 0x04001024 RID: 4132
		public float MarginTop;

		// Token: 0x04001025 RID: 4133
		public float MarginLeft;

		// Token: 0x04001026 RID: 4134
		public float MarginRight;

		// Token: 0x04001027 RID: 4135
		public float MarginBottom;

		// Token: 0x04001028 RID: 4136
		public float HAlign;

		// Token: 0x04001029 RID: 4137
		public float VAlign;

		// Token: 0x0400102A RID: 4138
		private CalculatedStyle _innerDimensions;

		// Token: 0x0400102B RID: 4139
		private CalculatedStyle _dimensions;

		// Token: 0x0400102C RID: 4140
		private CalculatedStyle _outerDimensions;

		// Token: 0x0400102D RID: 4141
		private static RasterizerState _overflowHiddenRasterizerState;

		// Token: 0x0400102E RID: 4142
		protected bool _useImmediateMode;

		// Token: 0x0400102F RID: 4143
		private SnapPoint _snapPoint;

		// Token: 0x04001030 RID: 4144
		private bool _isMouseHovering;

		// Token: 0x0200011A RID: 282
		// (Invoke) Token: 0x06000CA4 RID: 3236
		public delegate void MouseEvent(UIMouseEvent evt, UIElement listeningElement);

		// Token: 0x0200011B RID: 283
		// (Invoke) Token: 0x06000CA8 RID: 3240
		public delegate void ScrollWheelEvent(UIScrollWheelEvent evt, UIElement listeningElement);
	}
}
